package com.woniu.cq.medical.dao;

import com.woniu.cq.medical.controller.form.DutyQueryForm;
import com.woniu.cq.medical.entity.Duty;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Lucas
 * @since 2020-09-05
 */
public interface DutyMapper extends BaseMapper<Duty> {

    /**
     * 查询医生当天起7天之内的排班记录
     * @param doctorId
     * @param startTime
     * @param endTime
     * @return
     */
    List<Date> queryDutyDateList(Integer doctorId,@Param("startTime")Date startTime,@Param("endTime")Date endTime);

    @Select("select * from lonbon_duty where doctor_id=#{doctorId}")
    List<Duty> queryDutyList(Integer doctorId);

    @Select("select * from lonbon_duty where doctor_id=#{doctorId} and duty_date=#{dutyDate}")
    Duty queryDutyOne(Integer doctorId, LocalDate dutyDate);

    @Update("update lonbon_duty set now_book_people=#{nowBookPeople} where duty_id=#{dutyId}")
    int updateNowBookPeople(Integer nowBookPeople,Integer dutyId);

    int selectDoctorDuty(@Param("doctorId") int doctorId,@Param("date") Date date);

    long totalCount(@Param("administrativeName") String administrativeName,@Param("doctorName") String doctorName, @Param("dutyDateBefore") Date dutyDateBefore,@Param("dutyDateAfter") Date dutyDateAfter);

    List<DutyQueryForm> pageQuery(@Param("pageStart") int pageStart, @Param("pageSize") int pageSize, @Param("administrativeName") String administrativeName,@Param("doctorName") String doctorName, @Param("dutyDateBefore")Date dutyDateBefore,@Param("dutyDateAfter") Date dutyDateAfter);
}
